package com.sakiko.chat_image.config;

import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * projectName: com.sakiko.chat_image.config
 *
 * @author: sakiko
 * time: 2025/8/24 14:02
 * description: 知识出处
 * https://docs.langchain4j.dev/tutorials/chat-and-language-models/#image-content
 */

@Configuration
public class LLMConfig {

    //  图片理解 (langchain4j原生)
    @Bean
    public ChatModel ImageComprehensive() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("ALIBABA_BAILIAN_API_KEY"))
                .modelName("qwen-vl-plus")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    /**
     * 测试通义万象来实现图片生成
     * https://help.aliyun.com/zh/model-studio/text-to-image
     */
    @Bean
    public WanxImageModel wanxImageModel() {
        return WanxImageModel.builder()
                .apiKey(System.getenv("ALIBABA_BAILIAN_API_KEY"))
                .modelName("wanx2.1-t2i-turbo")
                .build();
    }
}
